版权声明:本文为博主原创文章,转载请注明出处:http://blog.jerkybible.com/2013/11/24/2013-11-24-CODE 137 Word Break II/
访问原文「CODE 137. Word Break II」
Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word.
Return all such possible sentences.
For example, given
s = "catsanddog"
,
dict = ["cat", "cats", "and", "sand", "dog"]
.
A solution is ["cats and dog", "cat sand dog"]
.
|
|